﻿@model MvcBugTrack.Models.Bug
@using MvcBugTrack.Models

@{
    ViewBag.Title = "Edit";
    BugTrackContext db = new BugTrackContext();
}

<h2>Edit</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Bug</legend>

        @Html.HiddenFor(model => model.ID)

        <div class="editor-label">
            @Html.LabelFor(model => model.ShortDescription)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ShortDescription)
            @Html.ValidationMessageFor(model => model.ShortDescription)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Project)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Project, new SelectList(db.Projects.ToList(), "ID", "Name"))
            @Html.ValidationMessageFor(model => model.Project)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Category)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Category, new SelectList(db.Categories.ToList(), "ID", "Name"))
            @Html.ValidationMessageFor(model => model.Category)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Priority)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Priority, new SelectList(db.Priorities.ToList(), "ID", "Name"))
            @Html.ValidationMessageFor(model => model.Priority)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Status)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Status, new SelectList(db.Statuses.ToList(), "ID", "Name"))
            @Html.ValidationMessageFor(model => model.Status)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.AssignedTo)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.AssignedTo, new SelectList(db.Users.ToList(), "ID", "UserName"))
            @Html.ValidationMessageFor(model => model.AssignedTo)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ReportedBy)
        </div>
        <div class="editor-field">
            @Html.Label(db.Users.Find(Model.ReportedBy).UserName)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
